﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>密码保护页</title>
    <script type="text/javascript">
        function password()
        {
            var inputCount = 1;
            //弹出密码输入框
            var pass1 = prompt('请输入密码(密码默认为password):','');
            //判断输入密码是否超过3次
            while (inputCount < 3) {
                if (!pass1)
                    history.go(-1);
                if (pass1 === "password") {
                    alert('密码正确!');
                    break;
                }
                inputCount+=1;
                //弹出错误信息提示
                var pass1 = prompt('密码错误!请重新输入:');
            }
            if (pass1!=="password" && inputCount === 3)
                history.go(-1);
            return " ";
        }
        document.write(password());
    </script>
</head>
<body>

</body>
</html>